<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout :: common_header(~{::title})">
    <title>退货订单-仓库管理系统</title>
</head>
<body th:replace="layout :: common_body(~{::div.layui-body})">

<div class="layui-body" style="padding:15px;top: 0px;">

    <!-- start sp-wrapper -->
    <link rel="stylesheet" href="/sb/stock.css"/>
    <fieldset class="layui-elem-field">
        <legend>按条件搜索</legend>
        <div class="layui-field-box">
            <form class="layui-form layui-form-pane1" method="get" action="/order_return/list">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <input type="text" name="refNum" placeholder="退款单号" class="layui-input" th:value="${refNum}">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="orderNum" placeholder="订单号" class="layui-input" th:value="${orderNum}">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="refMobile" placeholder="退货人手机号" class="layui-input" th:value="${refMobile}">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="logisticsCode" placeholder="买家发货物流单号" class="layui-input" th:value="${logisticsCode}">
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="status" id="status">
                                <option value="">全部</option>
                                <option th:each="item:${T(com.b2c.entity.enums.erp.EnumOrderReturnStatus).values()}"
                                        th:text="${item.name}" th:value="${item.index}">未发货
                                </option>
                            </select>
                        </div>
                    </div>
<!--                    <div class="layui-inline">-->
<!--                        <label class="layui-form-label">订单时间</label>-->
<!--                        <div class="layui-input-inline">-->
<!--                            <input type="text" class="layui-input" name="startTime" id="startTime"-->
<!--                                   placeholder="yyyy-MM-dd" autocomplete="off">-->
<!--                        </div>-->
<!--                        <div class="layui-input-inline">-->
<!--                            <input type="text" class="layui-input" name="endTime" id="endTime" placeholder="yyyy-MM-dd"-->
<!--                                   autocomplete="off">-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="layui-inline">
                        <button type="submit" class="layui-btn">搜索</button>
                        <i>总共：&nbsp;[[${totalSize}]]&nbsp;条记录</i>
                    </div>
                    <div class="layui-inline"></div>

                </div>
            </form>



        </div>
    </fieldset>
    <div class="sp-wrapper">
<!--        <h2 class="sp-title"><span>退货订单(<i th:text="${totalSize}" style="color: red"></i>)</span></h2>-->
<!--        <form action="/order_return/list" method="get">-->
<!--            <div class="sp-tool">-->
<!--            <span class="fl">-->
<!--                <b><input type="text" name="number"  th:value="${number}" placeholder="输入退货单号">-->
<!--                <input type="submit" value="查询">-->
<!--                </b>-->
<!--            </span>-->
<!--            </div>-->
<!--        </form>-->
        <div class="sp-table">
            <table>
                <thead>
                <tr>
                    <th>ID</th>
                    <th>退货单号</th>
                    <th>源订单号</th>
                    <th>来源店铺</th>
                    <th>退货确认时间</th>
                    <th>退货商品</th>
                    <!--<th>退货人信息</th>-->
                    <th>收货物流信息</th>
                    <th>状态</th>

                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="sp-data">
                <tr th:each="item:${list}">
                    <td th:text="${item.id}"></td>
                    <td th:text="${item.orderNum}">2019-03-15</td>
                    <td th:text="${item.sourceOrderNum}">2019-03-15</td>
<!--                    <td th:text="${T(com.b2c.entity.erp.enums.ErpOrderSourceEnum).getName(item.source)}"></td>-->
                    <td th:text="${item.shopName}"></td>

                    <td th:text="${#dates.format(item.createTime * 1000, 'yyyy-MM-dd HH:mm:ss')}">XS201903260932042</td>
                    <td >
                        <table>
                            <tr th:each="it:${item.items}">
                                <td >
                                    <img th:src="${it.colorImage}" width="50px;" height="50px;" />
                                </td>
                                <td th:text="${it.skuNumber}"></td>
                                <td >
                                    <b th:text="${it.colorValue}"></b><br />
                                    <b th:text="${it.sizeValue}"></b>
                                </td>
                                <td th:text="${it.quantity}"></td>
                                <td th:if="${item.status==T(com.b2c.entity.enums.erp.EnumOrderReturnStatus).WaitReceive.getIndex()}"><!--<a class="view upd_express" th:attr="data-id=${item.getId()}" href="javascript:;" >修改</a>--><a class="view addGoods" href="javascript:;" th:attr="data-id=${item.getId()}" >新增</a></td>
                            </tr>
                        </table>
                    </td>
                    <!--<td >
                    <b th:text="${item.contactPerson}"></b><br />
                        <b th:text="${item.mobile}"></b>
                    </td>-->

                    <td >
                    <b th:text="${item.logisticsCompany}"></b><br />
                    <b th:text="${item.logisticsCode}"></b>
                    </td>

                    <td>
                        <b th:text="${T(com.b2c.entity.enums.erp.EnumOrderReturnStatus).getName(item.status)}"></b>
                    </td>

                    <td>
                        <a class="view" target="_blank" th:href="@{/order_return/detail(id=${item.id})}"  >查看详情</a>&nbsp;<br/>
                        <a class="view upd_express" th:attr="data-id=${item.getId()}" href="javascript:;" th:if="${item.status==T(com.b2c.entity.enums.erp.EnumOrderReturnStatus).Received.getIndex() || item.status==T(com.b2c.entity.enums.erp.EnumOrderReturnStatus).WaitReceive.getIndex()}" >修改物流</a>&nbsp;<br/>
                        <a class="view confirmReceive2" target="_blank" th:if="${item.status==T(com.b2c.entity.enums.erp.EnumOrderReturnStatus).Received.getIndex() || item.status==T(com.b2c.entity.enums.erp.EnumOrderReturnStatus).WaitReceive.getIndex()}" th:href="@{/order_return/stock_info_list(id=${item.id})}" >确认收货</a>
<!--                        <a class="view confirmReceive" th:if="${item.status < T(com.b2c.entity.enums.erp.EnumOrderReturnStatus).Received.getIndex()}" th:attr="order-id=${item.id}" >确认收货</a>-->
<!--                        <a class="view confirmReceive1" target="_blank" th:if="${item.status==T(com.b2c.entity.enums.erp.EnumOrderReturnStatus).Received.getIndex()}" th:href="@{/order_return/bad_stock_list(id=${item.id})}" >放入不良品仓</a>-->
<!--                        <a class="view confirmReceive2" target="_blank" th:if="${item.status==T(com.b2c.entity.enums.erp.EnumOrderReturnStatus).Received.getIndex()}" th:href="@{/order_return/stock_info_list(id=${item.id})}" >合格入库</a>-->
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="pages">
                <paging:pager th:value="${pageIndex}" th:rows="${totalSize}" th:size="${pageSize}"/>
            </div>
        </div>
    </div>
    <script type="text/template" id="send-goods">
        <div class="T-box">
            <p><span>快递公司</span><input type="text" name="company"/></p>
            <p><span>快递单号</span><input type="text" name="express_code"/></p>
        </div>
    </script>
    <script type="text/template" id="addgoods">
        <div class="T-box">
            <p><span>规格编码</span><input type="text" name="specNum"/></p>
            <p><span>数量</span><input type="text" name="num"/></p>
        </div>
    </script>

    <script type="text/javascript" src="/sb/jquery.min.js"></script>
    <script type="text/javascript" src="/sb/Tips.min.js"></script>
    <script type="text/javascript">
        $(function () {

            function getDateTime(timestamp) {
                var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
                var Y = date.getFullYear();
                var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
                var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours());
                var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes());
                var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
                return Y + '-' + M + '-' + D + ' ' + h + ':' + m + ':' + s;
            }
        });
    </script>
    <!-- end sp-wrapper -->
    <script>
        layui.use(['laydate', 'layer','form'], function () {
            var laydate = layui.laydate;
            var layer = layui.layer;
            var form = layui.form;
            $("#status").val([[${status}]]);
            form.render('select'); //刷新select选择框渲染

            $(function () {
                // $(".confirmReceive").click(function () {
                //     var orderId = $(this).attr("order-id");
                //     layer.open({
                //         type: 2,
                //         title: '打印订单快递单',
                //         shadeClose: true,
                //         shade: 0.8,
                //         area: ['940px', '90%'],
                //         content: '/order_return/stock_info_list?id=' + orderId //iframe的url
                //     });
                //     // if(confirm("是否确定已收到货？")){
                //     //     $.ajax({
                //     //         url: '/order_return/confirm_receive',
                //     //         type: 'post',
                //     //         dataType: 'json',
                //     //         contentType: 'application/json',
                //     //         data: JSON.stringify({orderId:orderId}),
                //     //         success: function (res) {
                //     //             console.log(res);
                //     //             if(res.code == 0){
                //     //                 alert("确认成功");
                //     //                 window.location.reload();
                //     //             }else
                //     //                 Tips.alert(res.msg);
                //     //         }
                //     //     });
                //     // }
                //
                // });
            });
        })

        // 填写物流
        $('.upd_express').click(function (e) {
            e.stopPropagation();
            e.preventDefault();
            var id = $(this).attr('data-id');
            Tips.confirm({
                title: '修改退货物流',
                content: $('#send-goods').html(),
                define: function () {
                    var data = {
                        id: id,
                        company: $("input[name='company']").val(),
                        expressCode: $("input[name='express_code']").val()
                    };
                    $.ajax({
                        url: "/ajax_order/upd_erp_order_return_code",
                        type: "POST",
                        dataType: 'json',
                        contentType: 'application/json',
                        data: JSON.stringify(data),
                        success: function (res) {
                            if (res.code == 0) {
                                Tips.alert('成功', function () {
                                    location.reload(true);
                                });
                            } else {
                                Tips.alert(res.msg);
                            }
                        }
                    });
                }
            });
        });

        $('.addGoods').click(function (e) {
            e.stopPropagation();
            e.preventDefault();
            var id = $(this).attr('data-id');
            Tips.confirm({
                title: '添加商品',
                content: $('#addgoods').html(),
                define: function () {
                    var data = {
                        id: id,
                        specNum: $("input[name='specNum']").val(),
                        num: $("input[name='num']").val()
                    };
                    $.ajax({
                        url: "/ajax_order/add_erp_order_return_item",
                        type: "POST",
                        dataType: 'json',
                        contentType: 'application/json',
                        data: JSON.stringify(data),
                        success: function (res) {
                            if (res.code == 0) {
                                Tips.alert('成功', function () {
                                    location.reload(true);
                                });
                            } else {
                                Tips.alert(res.msg);
                            }
                        }
                    });
                }
            });
        });
    </script>
</div>
</body>
<html>
